package cn.edu.fzu.homemaking.company.service.impl;

import cn.edu.fzu.homemaking.company.domain.entity.OrderCompanyUser;
import cn.edu.fzu.homemaking.company.domain.enums.UserOrderStatusEnum;
import cn.edu.fzu.homemaking.company.mapper.OrdersCompanyUserMapper;
import cn.edu.fzu.homemaking.company.service.OrdersCompanyUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wanjie
 * @version 1.0
 */
@Service
public class OrdersCompanyUserServiceImpl implements OrdersCompanyUserService {

    @Resource
    private OrdersCompanyUserMapper ordersCompanyUserMapper;

    @Override
    public void add(String orderId, Long companyUserId) {
        OrderCompanyUser orderCompanyUser = new OrderCompanyUser();
        orderCompanyUser.setOrderId(orderId);
        orderCompanyUser.setCompanyUserId(companyUserId);
        orderCompanyUser.setStatus(UserOrderStatusEnum.TODO);
        ordersCompanyUserMapper.insertOrderCompanyUser(orderCompanyUser);
    }


    @Override
    public List<OrderCompanyUser> list(String orderId, Long companyUserId, UserOrderStatusEnum status) {
        return ordersCompanyUserMapper.list(orderId, companyUserId, status);
    }


    @Override
    public List<String> listNotDoneOrderId(Long companyUserId) {
        return ordersCompanyUserMapper.listNotDoneOrderId(companyUserId);
    }


    @Override
    public void updateOrderCompanyUser(String orderId, UserOrderStatusEnum status, Long companyUserId) {
        ordersCompanyUserMapper.updateOrderCompanyUser(orderId, status, companyUserId);
    }

}
